package org.galaxyworld.flycode.config;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@ConfigurationProperties(locations = "classpath:spy.yml")
@ToString
public class SpyConfig {

    public String sqlForSelectTables() {
        return getTargetPlatform().getSelectTables();
    }

    public String sqlForSelectViews() {
        return getTargetPlatform().getSelectViews();
    }

    public String sqlForSelectRowCount() {
        return getTargetPlatform().getSelectRowCount();
    }

    public String sqlForSelectColumnTypes() {
        return getTargetPlatform().getSelectColumnTypes();
    }

    public String sqlForSelectRoutines() {
        return getTargetPlatform().getSelectRoutines();
    }

    public String sqlForSelectRoutineParameters() {
        return getTargetPlatform().getSelectRoutineParameters();
    }

    private SpySQL getTargetPlatform() {
        return spy.get(AppConfig.getPlatform());
    }

    @Setter @Getter
    private Map<String, SpySQL> spy;

    @ToString
    public static class SpySQL {

        @Setter @Getter
        private String selectTables;

        @Setter @Getter
        private String selectViews;

        @Setter @Getter
        private String selectRowCount;

        @Setter @Getter
        private String selectColumnTypes;

        @Setter @Getter
        private String selectRoutines;

        @Setter @Getter
        private String selectRoutineParameters;
    }

}
